{include file="../app/common/admin/lib/header.html" title="活动管理"}
<div class="page-header border-bottom clearfix">
    <h2 class="left">活动管理<span>在这里对活动进行管理</span></h2>
    <a href="{:url('/activity/admin/add')}" class="btn btn-success btn-sm right"></i>添加</a>
    <a href="javascript:void(0);" class="btn btn-default btn-sm right js_advancedSearchBtn">搜索</a>
</div>
<div class="search-form js_advancedForm" style="{if !$search_filter}display:none;{/if}">
    <form action="/activity/admin" method="get">
        <input type="hidden" name="status" value="{$status}">
        <p>
            <label for="" class="search-f-label">标题：</label>
            <input type="text" class="search-f-ipt1" name="search_filter[title]" value="{$search_filter.title}">
        </p>
        <p>
            <label for="" class="search-f-label">添加时间：</label>
            <input type="text" class="search-f-ipt1 search-f-ipt2" name="search_filter[start_date]" value="{$search_filter.start_date}" id="startDate">
            <span class="search-f-line"></span>
            <input type="text" class="search-f-ipt1 search-f-ipt2" name="search_filter[stop_date]" value="{$search_filter.stop_date}" id="stopDate">
        </p>
        <p><label for="" class="search-f-label"></label><button type="submit" class="btn btn-success btn-xs js_searchBtn">搜索</button></p>
    </form>
</div>

<div class="filter-box">按状态：
    <a href='{:url("/activity/admin/index", ["status" => 1])}' {if $status == 1} class="label label-primary" {else} class="label label-default" {/if}>正常</a>
    <a href='{:url("/activity/admin/index", ["status" => 0])}' {if $status == 0} class="label label-primary" {else} class="label label-default" {/if}>已删除</a>
</div>
<table class="list-table">
    <thead><tr>
        <th style="width:20px;"><input type="checkbox" class="selectAll"></th>
        <th style="width:100px;">标题</th>
        <th style="width:260px;">链接</th>
        <th style="width:60px;">状态</th>
        <th style="width:130px;">添加时间</th>
        <th>操作</th>
    </tr></thead>
    <tbody>
    {if $list}
    {foreach $list as $k=>$v}
    <tr id="dataList{$v.id}" {if $k%2 == 1} class="bg-gray" {/if}>
    <td><input type="checkbox" class="listSelect"></td>
    <td>{$v.title}</td>
    <td><div style="white-space: nowrap;width: 120px;overflow: hidden; text-overflow: ellipsis;">{$v.content}</div></td>
    <td>{if $v.status}使用中{else /}已停止 {/if}</td>
    <td>{:time_format($v.add_time)}</td>
    <td>
        {if $status == 1}
        <!--
         <a href="{AnUrl("city/admin/edit?id={$v.id}")}" class="btn btn-success btn-xs">编辑</a>
         -->

        <a class="btn btn-xs btn-info" href='{:url("/activity/admin/edit",["id"=>$v.id])}'>编辑</a>
        <a href="{:url('/activity/admin/delete')}" class="btn btn-danger btn-xs deleteOne"><i class="icon-trash icon-white"></i>删除</a>

        {elseif $status == 0}
        <a href="{:url('/activity/admin/change_status', ['status'=>1])}" class="btn btn-success btn-xs changeStatus" data-confirm="确定要恢复该条记录吗？"><i class="icon-trash icon-white"></i>恢复</a>
        {/if}
    </td>
    </tr>
    {/foreach}
    {else /}
    <tr><td class="txtleft" colspan="7">暂无数据</td></tr>

    {/if}
    </tbody>
    <tfoot><tr><td><input type="checkbox" class="selectAll"></td><td colspan="9"><a href="{:url('/activity/admin/delete')}" class="btn btn-danger btn-xs deleteAll">批量删除</a></td></tr></tfoot>
</table>

<!--end:列表-->
<script>
    $(function(){
        // 高级搜索时间验证
        $('.js_searchBtn').click(function(e){
            e.preventDefault();
            var thisObj   = $(this);
            var startDate = $.trim($('#startDate').val());
            var stopDate  = $.trim($('#stopDate').val());
            if (startDate > stopDate) {
                showMsg('结束时间应大于等于开始时间');
                return;
            }
            thisObj.closest('form').submit();
        });

        $(".js_recommend").on('click', function(){
            var thisObj  = $(this);
            var is_recom = thisObj.attr('is_recom');
            var dataId  = thisObj.data("id");

            var url      = siteUrl+"/recommend/admin/add_recommend";
            var postData = { 'res_name':"information", "res_id":dataId };
            console.log(is_recom, dataId);
            $.post(url, postData, function(json){
                if (json.info != 'ok') {
                    showMsg(json.info);
                    return;
                }

                if (is_recom == 1) {
                    thisObj.attr('is_recom', 0);
                    thisObj.text('设为推荐');
                } else {
                    thisObj.attr('is_recom', 1);
                    thisObj.text('取消推荐');
                }
            }, 'json').error(function(){
                showMsg("请求出错");
                return;
            });
        });
    });
</script>
{include file="../app/common/admin/lib/footer.html"}